package de.szut.tictactoe.gui;

import javax.swing.JPanel;

public class TicTacToeFieldGenerator {
	private int x;
	private int y;
	private int buttonWidth;
	private int buttonHeight;
	private int distBetweenButtonsX;
	private int distBetweenButtonsY;
	private JPanel parentPanel;
	
	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public int getButtonWidth() {
		return buttonWidth;
	}

	public void setButtonWidth(int buttonWidth) {
		this.buttonWidth = buttonWidth;
	}

	public int getButtonHeight() {
		return buttonHeight;
	}

	public void setButtonHeight(int buttonHeight) {
		this.buttonHeight = buttonHeight;
	}

	public int getDistBetweenButtonsX() {
		return distBetweenButtonsX;
	}

	public void setDistBetweenButtonsX(int distBetweenButtonsX) {
		this.distBetweenButtonsX = distBetweenButtonsX;
	}

	public int getDistBetweenButtonsY() {
		return distBetweenButtonsY;
	}

	public void setDistBetweenButtonsY(int distBetweenButtonsY) {
		this.distBetweenButtonsY = distBetweenButtonsY;
	}

	public TicTacToeFieldGenerator(JPanel parentPanel) {
		this.parentPanel = parentPanel;
	}
	
	public void generateTicTacToeField() {
		/**
		 * blah blah default config
		 */
		
		buttonWidth = 40;
		buttonHeight = 40;
		distBetweenButtonsX = 20;
		distBetweenButtonsY = 20;
		System.out.println(MainFrame.getInstance().getWidth());
		x = MainFrame.getInstance().getWidth()/2 - buttonWidth - buttonWidth/2 - distBetweenButtonsX -2;
		y = MainFrame.getInstance().getHeight()/2 - buttonHeight - buttonHeight/2 - distBetweenButtonsY-20;
		
		/**
		 * blah blah generate field
		 */
		int[] offset = {buttonWidth+distBetweenButtonsX,buttonHeight+distBetweenButtonsY};
		TicButton[][] ticButtons = new TicButton[3][3];
		TicButtonListener listener = new TicButtonListener();
		for (int indexY = 0, currentPosY = y; indexY != 3; indexY ++, currentPosY += offset[1]) {
			for (int indexX = 0, currentPosX = x; indexX != 3; indexX ++, currentPosX += offset[0]) {
				ticButtons[indexX][indexY] = new TicButton();
				ticButtons[indexX][indexY].setBounds(currentPosX, currentPosY, buttonWidth, buttonHeight);
				ticButtons[indexX][indexY].addMouseListener()
				parentPanel.add(ticButtons[indexX][indexY]);
			}
		}
	}
}
